// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Y Bound Adjust Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 34 : TYPE_YBOUNDADJUST

// Static Values

// Tables

event ObjectMain
	if screen.cameraTarget == 0
		if object.propertyValue == 0
			temp0 = object[0].xpos
			temp0 -= object.xpos
			Abs(temp0)
			if temp0 < 0x200000
				stage.newYBoundary2 = object.iypos
				stage.deathBoundary = object.ypos
			end if
		else
			if object[0].ypos < object.ypos
				if object[0].ypos > object[+1].ypos
					temp0 = object[0].xpos
					temp0 -= object.xpos
					Abs(temp0)
					if temp0 < 0x200000
						stage.newYBoundary2 = object.iypos
						stage.deathBoundary = object.ypos
					end if
				end if
			end if
		end if
	end if
end event


event ObjectStartup
	foreach (TypeName[Y Bound Adjust], arrayPos0, ALL_ENTITIES)
		if object[arrayPos0].propertyValue == 0
			object[arrayPos0].priority = PRIORITY_XBOUNDS
			temp0 = object[0].xpos
			temp0 -= object[arrayPos0].xpos
			Abs(temp0)
			if temp0 < 0x200000
				stage.curYBoundary2 = object[arrayPos0].iypos
				stage.deathBoundary = object[arrayPos0].ypos
			end if
		else
			object[arrayPos0].priority = PRIORITY_XBOUNDS
			arrayPos1 = arrayPos0
			arrayPos1++
			if object[0].ypos < object[arrayPos0].ypos
				if object[0].ypos > object[arrayPos1].ypos
					temp0 = object[0].xpos
					temp0 -= object[arrayPos0].xpos
					Abs(temp0)
					if temp0 < 0x200000
						stage.curYBoundary2 = object[arrayPos0].iypos
						stage.deathBoundary = object[arrayPos0].ypos
					end if
				end if
			end if
		end if
	next
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
